#ifndef NETWORK_H
#define NETWORK_H

	// Network Libraries
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <netdb.h>
  
  // Struct to hold address and port number of sender
  struct addressPort {  
    //4-byte IP address
    unsigned int address;
    
    //2-byte port number
    unsigned short port;
  };
  
  // Configures network settings for sender and receiver 
  int networkConfigure (unsigned short port);
  
  // Checks the port number. If successful, returns the port number.
  int checkPort(char * enteredPort);

  // Configures the host's sockaddr struct in preparation for the call to bind
  struct sockaddr * configureHost (unsigned short port);
  
  // Sends a message via UDP
  void sendUDP(char * address, unsigned short port, int socketfd, char * msg, int msgLen);
  
  // Receives a message via UDP
  int receiveUDP(int socketfd, unsigned char * buffer, int bufferLen, struct sockaddr * senderSockAddr);
  
  // Extracts port and IP address from a given sockaddr struct
  void getAddressPort (struct sockaddr * senderSockAddr, struct addressPort * senderAddress);
  
  // Converts a 32-bit IP address to string notation
  char * ipToString (unsigned int address);

  
#endif